Methods and systems for bulk row save logic in an object relational mapping layer and application framework

ABSTRACT

In accordance with embodiments, there are provided mechanisms and methods for saving multiple rows together through an object relational mapping layer to a database. These mechanisms and methods for saving multiple rows together can enable embodiments to detect faults in the save operation(s) and recover. The ability of embodiments to detect faults in the save operation(s) and recover can enable embodiments to provide a robust forgiving published API that saves a set of rows together whenever possible.

CROSS REFERENCE TO RELATED APPLICATIONS

This application claims the benefit of U.S. Provisional PatentApplication 60/849,693 entitled METHOD FOR IMPLEMENTING BOTH BULK ANDROW BASED SAVE LOGIC IN AN OBJECT RELATIONAL MAPPING LAYER ANDAPPLICATION FRAMEWORK, by Craig Weissman et al., filed Oct. 4, 2006(Attorney Docket No. 021735-002900US), the entire contents of which areincorporated herein by reference.

U.S. patent application Ser. No. 11/______, entitled METHODS AND SYSTEMSFOR PROVIDING FAULT RECOVERY TO SIDE EFFECTS OCCURRING DURING DATAPROCESSING, by Craig Weissman et al., filed on even date herewith(Attorney Docket No. 021735-002920US) is related to the presentapplication, and is hereby incorporated by reference herein.

COPYRIGHT NOTICE

A portion of the disclosure of this patent document contains materialwhich is subject to copyright protection. The copyright owner has noobjection to the facsimile reproduction by anyone of the patent documentor the patent disclosure, as it appears in the Patent and TrademarkOffice patent file or records, but otherwise reserves all copyrightrights whatsoever.

FIELD OF THE INVENTION

The current invention relates generally to bulk save mechanisms in adatabase network system.

BACKGROUND

The subject matter discussed in the background section should not beassumed to be prior art merely as a result of its mention in thebackground section. Similarly, a problem mentioned in the backgroundsection or associated with the subject matter of the background sectionshould not be assumed to have been previously recognized in the priorart. The subject matter in the background section merely representsdifferent approaches, which in and of themselves may also be inventions.

In conventional database systems, users access their data resources inone logical database. A user of such a conventional system typicallyretrieves data from and stores data on the system using the user's ownsystems. A user system might remotely access one of a plurality ofserver systems that might in turn access the database system. Dataretrieval from the system might include the issuance of a query from theuser system to the database system. The database system might processthe request for information received in the query and send to the usersystem information relevant to the request. During this process, datamay be transformed through various formats and protocols in the varioustiers of the system: from XML or HTML text to Java Objects to relationaldata structures and back again. In particular the latter transition isknown in the industry as the O/R (object/relational) boundary and is thesubject of much developer headache and 3rd party development toolsupport (because the representation one uses typically in a procedurallanguage like Java, for a complex object, is typically quite differentfrom the optimal manner in which that data is stored and indexed in arelational database (which is the dominant location for enterprise dataof this sort)).

Unfortunately, conventional 3rd party approaches to lower-level O/Rprocessing do not support save operations performed in bulk, becominginefficient if, for example, the number of items to be saved to thedatabase system is relatively high.

Accordingly, it is desirable to provide techniques enabling an API ofthe database system to improve performance and provide greaterrobustness of the database system.

BRIEF SUMMARY

In accordance with embodiments, there are provided mechanisms andmethods for saving multiple rows together through an object relationalmapping layer to a database. These mechanisms and methods for savingmultiple rows together can enable embodiments to detect faults in thesave operation(s) and recover. The ability of embodiments to detectfaults in the save operation(s) and recover can enable embodiments toprovide a robust forgiving published API that saves a set of rowstogether whenever possible.

In an embodiment and by way of example, a method for saving multiplerows together through an object relational mapping layer to a databaseis provided. The method embodiment includes receiving, at an API in aknown start state, a set of rows to save together. The set of rows issaved together until each row in the set of rows has been saved. A newset of rows is formed from the set of rows by removing rows associatedwith faulting during saving. The saving and forming can be repeatedusing the new set of rows until a set of rows that can be saved from theknown start state without fault is determined. When a set of rows thatcan be saved from the known start state without fault is determined,then the set of rows may be committed.

In another embodiment and again by way of example, a method forproviding fault recovery to side effects occurring during dataprocessing is provided. The method embodiment includes detecting a faultin processing a set of rows of a database. At least one of the set ofrows includes at least one side effect. Each of the set of rowsprocessed can be rolled back and processing retried on a subset of theset of rows in which rows associated with faults have been removed untila subset of the set of rows in which each row of the subset of rows isable to be processed. The subset of rows may be processed to thedatabase and the at least one side effect executed, thereby ensuringthat no side effects have occurred from executing code on behalf of anyrows associated with a fault.

While the present invention is described with reference to an embodimentin which techniques for saving multiple rows together are implemented ina system having an application server providing a front end for anon-demand database service capable of supporting multiple tenants, thepresent invention is not limited to multi-tenant databases nordeployment on application servers. Embodiments may be practiced usingother database architectures, i.e., ORACLE®, DB2® by IBM and the likewithout departing from the scope of the embodiments claimed.

Any of the above embodiments may be used alone or together with oneanother in any combination. Inventions encompassed within thisspecification may also include embodiments that are only partiallymentioned or alluded to or are not mentioned or alluded to at all inthis brief summary or in the abstract. Although various embodiments ofthe invention may have been motivated by various deficiencies with theprior art, which may be discussed or alluded to in one or more places inthe specification, the embodiments of the invention do not necessarilyaddress any of these deficiencies. In other words, different embodimentsof the invention may address different deficiencies that may bediscussed in the specification. Some embodiments may only partiallyaddress some deficiencies or just one deficiency that may be discussedin the specification, and some embodiments may not address any of thesedeficiencies.

BRIEF DESCRIPTION OF THE DRAWINGS

In the following drawings like reference numbers are used to refer tolike elements. Although the following figures depict various examples ofthe invention, the invention is not limited to the examples depicted inthe figures.

FIG. 1 illustrates a block diagram of an example of an environmentwherein an on-demand database service might be used;

FIG. 2 illustrates a block diagram of an embodiment of elements of FIG.1 and various possible interconnections between these elements;

FIG. 3A illustrates an operational flow diagram of a high level overviewof a technique for saving multiple rows together in an embodiment;

FIG. 3B illustrates an operational flow diagram of a high level overviewof a technique for providing fault recovery to side effects occurringduring data processing in an embodiment; and

FIGS. 4A-4B illustrate block diagrams of an example of a technique forsaving multiple rows together in an embodiment.

DETAILED DESCRIPTION General Overview

Systems and methods are provided for saving multiple rows togetherthrough an object relational mapping layer to a database. Savingmultiple rows together can enable embodiments to detect faults in thesave operation(s) and recover. Embodiments may recover from faults byforming a new set of rows by removing rows associated with faulting saveoperations and repeating the saving and forming operations using the newset of rows until a set of rows that can be saved from the known startstate without fault is determined. When the subset of successful rows isfound, embodiments are able to provide assurance that no side effects(i.e., code or operations triggered by saving of a data to a particularlocation) have been executed on behalf of any of the failed rows (sideeffects from custom PL/SOQL code included) by deferring execution oftriggers until an entire set of rows can be saved and committed.

When a rollback of save operations occurs responsive to a fault detectedin one or more save operations, a whole service notion ofrollback—including rollback of governor limits (i.e., limits placed onresource usage)—can be performed. Rollback of an entire service providesa simple and easy to understand programming model to the user becauseusers do not need to worry about the retry logic itself using upresource limits in unpredictable ways.

Embodiments process data from clients using a bulk array for efficiencyand speed, including techniques in multiple programming environments andlanguages. As an example, a client-side Simple Object Access Protocol(SOAP) API embodiment saves can be specified as arrays of objects toencourage efficient use of Internet round trips.

As used herein, the term multi-tenant database system refers to thosesystems in which various elements of hardware and software of thedatabase system may be shared by one or more customers. For example, agiven application server may simultaneously process requests for a greatnumber of customers, and a given database table may store rows for apotentially much greater number of customers. As used herein, the termquery plan refers to a set of steps used to access information in adatabase system.

Next, mechanisms and methods for saving multiple rows together throughan object relational mapping layer to a database will be described withreference to example embodiments.

System Overview

FIG. 1 illustrates a block diagram of an environment 10 wherein anon-demand database service might be used. Environment 10 may includeuser systems 12, network 14, system 16, processor system 17, applicationplatform 18, network interface 20, tenant data storage 22, system datastorage 24, program code 26, and process space 28. In other embodiments,environment 10 may not have all of the components listed and/or may haveother elements instead of, or in addition to, those listed above.

Environment 10 is an environment in which an on-demand database serviceexists. User system 12 may be any machine or system that is used by auser to access a database user system. For example, any of user systems12 can be a handheld computing device, a mobile phone, a laptopcomputer, a work station, and/or a network of computing devices. Asillustrated in FIG. 1 (and in more detail in FIG. 2) user systems 12might interact via a network 14 with an on-demand database service,which is system 16.

An on-demand database service, such as system 16, is a database systemthat is made available to outside users that do not need to necessarilybe concerned with building and/or maintaining the database system, butinstead may be available for their use when the users need the databasesystem (e.g., on the demand of the users). Some on-demand databaseservices may store information from one or more tenants stored intotables of a common database image to form a multi-tenant database system(MTS). Accordingly, “on-demand database service 16” and “system 16” willbe used interchangeably herein. A database image may include one or moredatabase objects. A relational database management system (RDMS) or theequivalent may execute storage and retrieval of information against thedatabase object(s). Application platform 18 may be a framework thatallows the applications of system 16 to run, such as the hardware and/orsoftware, e.g., the operating system. In an embodiment, on-demanddatabase service 16 may include an application platform 18 that enablescreation, managing and executing one or more applications developed bythe provider of the on-demand database service, users accessing theon-demand database service via user systems 12, or third partyapplication developers accessing the on-demand database service via usersystems 12.

The users of user systems 12 may differ in their respective capacities,and the capacity of a particular user system 12 might be entirelydetermined by permissions (permission levels) for the current user. Forexample, where a salesperson is using a particular user system 12 tointeract with system 16, that user system has the capacities allotted tothat salesperson. However, while an administrator is using that usersystem to interact with system 16, that user system has the capacitiesallotted to that administrator. In systems with a hierarchical rolemodel, users at one permission level may have access to applications,data, and database information accessible by a lower permission leveluser, but may not have access to certain applications, databaseinformation, and data accessible by a user at a higher permission level.Thus, different users will have different capabilities with regard toaccessing and modifying application and database information, dependingon a user's security or permission level.

Network 14 is any network or combination of networks of devices thatcommunicate with one another. For example, network 14 can be any one orany combination of a LAN (local area network), WAN (wide area network),telephone network, wireless network, point-to-point network, starnetwork, token ring network, hub network, or other appropriateconfiguration. As the most common type of computer network in currentuse is a TCP/IP (Transfer Control Protocol and Internet Protocol)network, such as the global internetwork of networks often referred toas the “Internet” with a capital “I,” that network will be used in manyof the examples herein. However, it should be understood that thenetworks that the present invention might use are not so limited,although TCP/IP is a frequently implemented protocol.

User systems 12 might communicate with system 16 using TCP/IP and, at ahigher network level, use other common Internet protocols tocommunicate, such as HTTP, FTP, AFS, WAP, etc. In an example where HTTPis used, user system 12 might include an HTTP client commonly referredto as a “browser” for sending and receiving HTTP messages to and from anHTTP server at system 16. Such an HTTP server might be implemented asthe sole network interface between system 16 and network 14, but othertechniques might be used as well or instead. In some implementations,the interface between system 16 and network 14 includes load sharingfunctionality, such as round-robin HTTP request distributors to balanceloads and distribute incoming HTTP requests evenly over a plurality ofservers. At least as for the users that are accessing that server, eachof the plurality of servers has access to the MTS′ data; however, otheralternative configurations may be used instead.

In one embodiment, system 16, shown in FIG. 1, implements a web-basedcustomer relationship management (CRM) system. For example, in oneembodiment, system 16 includes application servers configured toimplement and execute CRM software applications as well as providerelated data, code, forms, webpages and other information to and fromuser systems 12 and to store to, and retrieve from, a database systemrelated data, objects, and Webpage content. With a multi-tenant system,data for multiple tenants may be stored in the same physical databaseobject, however, tenant data typically is arranged so that data of onetenant is kept logically separate from that of other tenants so that onetenant does not have access to another tenant's data, unless such datais expressly shared. In certain embodiments, system 16 implementsapplications other than, or in addition to, a CRM application. Forexample, system 16 may provide tenant access to multiple hosted(standard and custom) applications, including a CRM application. User(or third party developer) applications, which may or may not includeCRM, may be supported by the application platform 18, which managescreation, storage of the applications into one or more database objectsand executing of the applications in a virtual machine in the processspace of the system 16.

One arrangement for elements of system 16 is shown in FIG. 1, includinga network interface 20, application platform 18, tenant data storage 22for tenant data 23, system data storage 24 for system data 25 accessibleto system 16 and possibly multiple tenants, program code 26 forimplementing various functions of system 16, and a process space 28 forexecuting MTS system processes and tenant-specific processes, such asrunning applications as part of an application hosting service.Additional processes that may execute on system 16 include databaseindexing processes.

Several elements in the system shown in FIG. 1 include conventional,well-known elements that are explained only briefly here. For example,each user system 12 could include a desktop personal computer,workstation, laptop, PDA, cell phone, or any wireless access protocol(WAP) enabled device or any other computing device capable ofinterfacing directly or indirectly to the Internet or other networkconnection. User system 12 typically runs an HTTP client, e.g., abrowsing program, such as Microsoft's Internet Explorer browser,Netscape's Navigator browser, Opera's browser, or a WAP-enabled browserin the case of a cell phone, PDA or other wireless device, or the like,allowing a user (e.g., subscriber of the multi-tenant database system)of user system 12 to access, process and view information, pages andapplications available to it from system 16 over network 14. Each usersystem 12 also typically includes one or more user interface devices,such as a keyboard, a mouse, trackball, touch pad, touch screen, pen orthe like, for interacting with a graphical user interface (GUI) providedby the browser on a display (e.g., a monitor screen, LCD display, etc.)in conjunction with pages, forms, applications and other informationprovided by system 16 or other systems or servers. For example, the userinterface device can be used to access data and applications hosted bysystem 16, and to perform searches on stored data, and otherwise allow auser to interact with various GUI pages that may be presented to a user.As discussed above, embodiments are suitable for use with the Internet,which refers to a specific global internetwork of networks. However, itshould be understood that other networks can be used instead of theInternet, such as an intranet, an extranet, a virtual private network(VPN), a non-TCP/IP based network, any LAN or WAN or the like.

According to one embodiment, each user system 12 and all of itscomponents are operator configurable using applications, such as abrowser, including computer code run using a central processing unitsuch as an Intel Pentium® processor or the like. Similarly, system 16(and additional instances of an MTS, where more than one is present) andall of their components might be operator configurable usingapplication(s) including computer code to run using a central processingunit such as processor system 17, which may include an Intel Pentium®processor or the like, and/or multiple processor units. A computerprogram product embodiment includes a machine-readable storage medium(media) having instructions stored thereon/in which can be used toprogram a computer to perform any of the processes of the embodimentsdescribed herein. Computer code for operating and configuring system 16to intercommunicate and to process webpages, applications and other dataand media content as described herein are preferably downloaded andstored on a hard disk, but the entire program code, or portions thereof,may also be stored in any other volatile or non-volatile memory mediumor device as is well known, such as a ROM or RAM, or provided on anymedia capable of storing program code, such as any type of rotatingmedia including floppy disks, optical discs, digital versatile disk(DVD), compact disk (CD), microdrive, and magneto-optical disks, andmagnetic or optical cards, nanosystems (including molecular memory ICs),or any type of media or device suitable for storing instructions and/ordata. Additionally, the entire program code, or portions thereof, may betransmitted and downloaded from a software source over a transmissionmedium, e.g., over the Internet, or from another server, as is wellknown, or transmitted over any other conventional network connection asis well known (e.g., extranet, VPN, LAN, etc.) using any communicationmedium and protocols (e.g., TCP/IP, HTTP, HTTPS, Ethernet, etc.) as arewell known. It will also be appreciated that computer code forimplementing embodiments of the present invention can be implemented inany programming language that can be executed on a client system and/orserver or server system such as, for example, C, C++, HTML, any othermarkup language, Java™, JavaScript, ActiveX, any other scriptinglanguage, such as VBScript, and many other programming languages as arewell known may be used. (Java™ is a trademark of Sun Microsystems,Inc.).

According to one embodiment, each system 16 is configured to providewebpages, forms, applications, data and media content to user (client)systems 12 to support the access by user systems 12 as tenants of system16. As such, system 16 provides security mechanisms to keep eachtenant's data separate unless the data is shared. If more than one MTSis used, they may be located in close proximity to one another (e.g., ina server farm located in a single building or campus), or they may bedistributed at locations remote from one another (e.g., one or moreservers located in city A and one or more servers located in city B). Asused herein, each MTS could include one or more logically and/orphysically connected servers distributed locally or across one or moregeographic locations. Additionally, the term “server” is meant toinclude a computer system, including processing hardware and processspace(s), and an associated storage system and database application(e.g., OODBMS or RDBMS) as is well known in the art. It should also beunderstood that “server system” and “server” are often usedinterchangeably herein. Similarly, the database object described hereincan be implemented as single databases, a distributed database, acollection of distributed databases, a database with redundant online oroffline backups or other redundancies, etc., and might include adistributed database or storage network and associated processingintelligence.

FIG. 2 also illustrates environment 10. However, in FIG. 2 elements ofsystem 16 and various interconnections in an embodiment are furtherillustrated. FIG. 2 shows that user system 12 may include processorsystem 12A, memory system 12B, input system 12C, and output system 12D.FIG. 2 shows network 14 and system 16. FIG. 2 also shows that system 16may include tenant data storage 22, tenant data 23, system data storage24, system data 25, User Interface (UI) 30, Application ProgramInterface (API) 32, PL/SOQL 34, save routines 36, application setupmechanism 38, applications servers 100 ₁-100 _(N), system process space102, tenant process spaces 104, tenant management process space 110,tenant storage area 112, user storage 114, and application metadata 116.In other embodiments, environment 10 may not have the same elements asthose listed above and/or may have other elements instead of, or inaddition to, those listed above.

User system 12, network 14, system 16, tenant data storage 22, andsystem data storage 24 were discussed above in FIG. 1. Regarding usersystem 12, processor system 12A may be any combination of one or moreprocessors. Memory system 12B may be any combination of one or morememory devices, short term, and/or long term memory. Input system 12Cmay be any combination of input devices, such as one, or more keyboards,mice, trackballs, scanners, cameras, and/or interfaces to networks.Output system 12D may be any combination of output devices, such as oneor more monitors, printers, and/or interfaces to networks. As shown byFIG. 2, system 16 may include a network interface 20 (of FIG. 1)implemented as a set of HTTP application servers 100, an applicationplatform 18, tenant data storage 22, and system data storage 24. Alsoshown is system process space 102, including individual tenant processspaces 104 and a tenant management process space 110. Each applicationserver 100 may be configured to tenant data storage 22 and the tenantdata 23 therein, and system data storage 24 and the system data 25therein to serve requests of user systems 12. The tenant data 23 mightbe divided into individual tenant storage areas 112, which can be eithera physical arrangement and/or a logical arrangement of data. Within eachtenant storage area 112, user storage 114 and application metadata 116might be similarly allocated for each user. For example, a copy of auser's most recently used (MRU) items might be stored to user storage114. Similarly, a copy of MRU items for an entire organization that is atenant might be stored to tenant storage area 112. A UI 30 provides auser interface and an API 32 provides an application programmerinterface to system 16 resident processes to users and/or developers atuser systems 12. The tenant data and the system data may be stored invarious databases, such as one or more Oracle™ databases.

Application platform 18 includes an application setup mechanism 38 thatsupports application developers' creation and management ofapplications, which may be saved as metadata into tenant data storage 22by save routines 36 for execution by subscribers as one or more tenantprocess spaces 104 managed by tenant management process 110 for example.Invocations to such applications may be coded using PL/SOQL 34 thatprovides a programming language style interface extension to API 32. Adetailed description of some PL/SOQL language embodiments is discussedin commonly owned co-pending U.S. Provisional Patent Application60/828,192 entitled, PROGRAMMING LANGUAGE METHOD AND SYSTEM FOREXTENDING APIS TO EXECUTE IN CONJUNCTION WITH DATABASE APIS, by CraigWeissman, filed Oct. 4, 2006, which is incorporated in its entiretyherein for all purposes. Invocations to applications may be detected byone or more system processes, which manages retrieving applicationmetadata 116 for the subscriber making the invocation and executing themetadata as an application in a virtual machine.

Each application server 100 may be communicably coupled to databasesystems, e.g., having access to system data 25 and tenant data 23, via adifferent network connection. For example, one application server 100,might be coupled via the network 14 (e.g., the Internet), anotherapplication server 100 _(N-1) might be coupled via a direct networklink, and another application server 100 _(N) might be coupled by yet adifferent network connection. Transfer Control Protocol and InternetProtocol (TCP/IP) are typical protocols for communicating betweenapplication servers 100 and the database system. However, it will beapparent to one skilled in the art that other transport protocols may beused to optimize the system depending on the network interconnect used.

In certain embodiments, each application server 100 is configured tohandle requests for any user associated with any organization that is atenant. Because it is desirable to be able to add and remove applicationservers from the server pool at any time for any reason, there ispreferably no server affinity for a user and/or organization to aspecific application server 100. In one embodiment, therefore, aninterface system implementing a load balancing function (e.g., an F5Big-IP load balancer) is communicably coupled between the applicationservers 100 and the user systems 12 to distribute requests to theapplication servers 100. In one embodiment, the load balancer uses aleast connections algorithm to route user requests to the applicationservers 100. Other examples of load balancing algorithms, such as roundrobin and observed response time, also can be used. For example, incertain embodiments, three consecutive requests from the same user couldhit three different application servers 100, and three requests fromdifferent users could hit the same application server 100. In thismanner, system 16 is multi-tenant, wherein system 16 handles storage of,and access to, different objects, data and applications across disparateusers and organizations.

As an example of storage, one tenant might be a company that employs asales force where each salesperson uses system 16 to manage their salesprocess. Thus, a user might maintain contact data, leads data, customerfollow-up data, performance data, goals and progress data, etc., allapplicable to that user's personal sales process (e.g., in tenant datastorage 22). In an example of a MTS arrangement, since all of the dataand the applications to access, view, modify, report, transmit,calculate, etc., can be maintained and accessed by a user system havingnothing more than network access, the user can manage his or her salesefforts and cycles from any of many different user systems. For example,if a salesperson is visiting a customer and the customer has Internetaccess in their lobby, the salesperson can obtain critical updates as tothat customer while waiting for the customer to arrive in the lobby.

While each user's data might be separate from other users' dataregardless of the employers of each user, some data might beorganization-wide data shared or accessible by a plurality of users orall of the users for a given organization that is a tenant. Thus, theremight be some data structures managed by system 16 that are allocated atthe tenant level while other data structures might be managed at theuser level. Because an MTS might support multiple tenants includingpossible competitors, the MTS should have security protocols that keepdata, applications, and application use separate. Also, because manytenants may opt for access to an MTS rather than maintain their ownsystem, redundancy, up-time, and backup are additional functions thatmay be implemented in the MTS. In addition to user-specific data andtenant-specific data, system 16 might also maintain system level datausable by multiple tenants or other data. Such system level data mightinclude industry reports, news, postings, and the like that are sharableamong tenants.

In certain embodiments, user systems 12 (which may be client systems)communicate with application servers 100 to request and updatesystem-level and tenant-level data from system 16 that may requiresending one or more queries to tenant data storage 22 and/or system datastorage 24. System 16 (e.g., an application server 100 in system 16)automatically generates one or more SQL statements (e.g., one or moreSQL queries) that are designed to access the desired information. Systemdata storage 24 may generate query plans to access the requested datafrom the database.

Each database can generally be viewed as a collection of objects, suchas a set of logical tables, containing data fitted into predefinedcategories. A “table” is one representation of a data object, and may beused herein to simplify the conceptual description of objects and customobjects according to the present invention. It should be understood that“table” and “object” may be used interchangeably herein. Each tablegenerally contains one or more data categories logically arranged ascolumns or fields in a viewable schema. Each row or record of a tablecontains an instance of data for each category defined by the fields.For example, a CRM database may include a table that describes acustomer with fields for basic contact information such as name,address, phone number, fax number, etc. Another table might describe apurchase order, including fields for information such as customer,product, sale price, date, etc. In some multi-tenant database systems,standard entity tables might be provided for use by all tenants. For CRMdatabase applications, such standard entities might include tables forAccount, Contact, Lead, and Opportunity data, each containingpre-defined fields. It should be understood that the word “entity” mayalso be used interchangeably herein with “object” and “table”.

In some multi-tenant database systems, tenants may be allowed to createand store custom objects, or they may be allowed to customize standardentities or objects, for example by creating custom fields for standardobjects, including custom index fields. U.S. patent application Ser. No.10/817,161, filed Apr. 2, 2004, entitled “CUSTOM ENTITIES AND FIELDS INA MULTI-TENANT DATABASE SYSTEM”, and which is hereby incorporated hereinby reference, teaches systems and methods for creating custom objects aswell as customizing standard objects in a multi-tenant database system.In certain embodiments, for example, all custom entity data rows arestored in a single multi-tenant physical table, which may containmultiple logical tables per organization. It is transparent to customersthat their multiple “tables” are in fact stored in one large table orthat their data may be stored in the same table as the data of othercustomers.

The following detailed description will first describe a high leveloverview of a technique for saving multiple rows together in accordancewith aspects and embodiments of the present invention. An example ofdetecting and recovering from failures in a save of multiple rows isthen detailed. Following the example of detecting and recovering fromfailures, examples of some of the many types of operations that may beperformed together in sets according to the techniques described hereinare provided.

FIG. 3 illustrates an operational flow diagram of a high level overviewof a technique for saving multiple rows together in an embodiment. Inone embodiment, the technique for saving multiple rows together shown inFIG. 3 is operable with an implemented in the multi-tenant databasesystem 16. As shown in FIG. 3, a set of rows to save together isreceived (block 302) at an API in a known start state. For example andwithout limitation, this can include receiving information to save to aset of rows in a Simple Object Access Protocol (SOAP) transaction.

The set of rows is saved (block 304) together until each row in the setof rows has been saved. By way of example and without limitation, thiscan include recording fault information for any row associated with asave operation that faults. A new set of rows is formed (block 306) fromthe set of rows by removing rows associated with faulting during saving.In embodiments, this can include removing rows corresponding to faultsfrom the set of rows to save together to form the new set of rows tosave together.

The saving (block 304) and forming (block 306) can be repeated (block308) using the new set of rows until a set of rows that can be savedfrom the known start state without fault is determined. This can includerolling back saving the set of rows to the known start state.Embodiments may roll back governor limits (i.e., resource limitations)placed upon code executing on behalf of rows that are being rolled backin order to prevent resource allocations from being used up by user'strying a procedure, detecting a failure and then rolling back theprocedure in the user's code. A detailed description of governor limitsin PL/SOQL language embodiments may be found in commonly ownedco-pending U.S. Provisional Patent Application 60/828,757 entitled,PROGRAMMING LANGUAGE METHOD AND SYSTEM FOR EXTENDING APIS TO EXECUTE INCONJUNCTION WITH DATABASE APIS, by Craig Weissman, filed Oct. 9, 2006,which is incorporated in its entirety herein for all purposes.

When a set of rows that can be saved from the known start state withoutfault is determined, then the set of rows may be committed (block 310).By executing side effects, such as code or operations execution istriggered by saving or other operations performed on data to certainrows, only after a set of rows is successfully saved and committed, theprocess of determining that a set of rows can be saved without incurringa fault enables embodiments to ensure that no side effects have occurredfrom executing code on behalf of any rows failing to be saved.

FIG. 3B is an operational flow diagram illustrating a high leveloverview of a technique for providing fault recovery to side effectsoccurring during data processing in an embodiment. A fault in processinga set of rows of a database is detected (block 312). At least one of theset of rows includes at least one side effect. For example and withoutlimitation, this can include at least one of a pre-operation trigger, apost-operation trigger, or a code snippet. Each of the set of rowsprocessed is rolled back (block 314) and processing is retried on asubset of the set of rows in which rows associated with faults have beenremoved until a subset of the set of rows in which each row of thesubset of rows is able to be processed (block 316). By way of exampleand without limitation, this can include rolling back governor limitsplaced upon code executing on behalf of rows that are being rolled back.The subset of rows is processed (block 318) to the database and the atleast one side effect is executed, thereby ensuring that no side effectshave occurred from executing code on behalf of any rows associated witha fault. In embodiments, this can include updating resources used andchecking against governor limits.

FIGS. 4A-4B illustrate block diagrams of an example of a technique forsaving multiple rows together in an embodiment. In FIG. 4A, a set ofrows 402-408 are to be saved together into a tenant data area 114 ofdatabase 22 of FIG. 2. Rows 402 and 408 have side effects associatedwith them, namely code snippet 402 a is triggered to execute prior tosaving row 402. Code snippet 402 a could also be triggered after saving402 or any other of a variety of trigger configurations. Similarly, row408 includes a code snippet 408 a that is triggered to execute prior tosaving row 408. Again, other types of triggers could be used, butpre-saving triggers are selected for this example for illustrativepurposes.

Again with reference to FIG. 4A, in an embodiment and by way of example,a first attempt to save rows 402-408 results in failure reports (“x”)being returned for row C 404 and row E 408. Because one or more failurereports have been received responsive to an attempted save operation,the save operations of rows 402-408 are rolled back to the startingstate. Further, any side effects 402 a, 408 a that were permitted toexecute are also rolled back. Additionally, any resource usage countedagainst governor limits by executing side effects 402 a, 408 a is alsorolled back.

Now with reference to FIG. 4B, a second attempt is made to find a blockof rows that can be saved without receiving failure reports. Asillustrated in FIG. 4B, row C 404 and row E 408 are removed from the setof rows that the system is attempting to save to the tenant data 114 ofdatabase 22 because row C 404 and row E 408 are associated with a priorfailing save operation. Now a new set of rows, including row B 402 androw D 406 are saved to tenant data 114, resulting in good return codes(“ok”). Accordingly, the system will once again roll back the save,execute any code or operations associated with pre-save triggerscorresponding to rows to be saved, such as snippet 402 a, perform a saveof the block of rows and then commit the saved rows. In the foregoingexample, the process of determining that a set of rows can be savedwithout incurring a fault enables embodiments to ensure that no sideeffects have occurred from executing code on behalf of any rows failingto be saved.

Bulk processing techniques provided by embodiments described herein canextend to processing any of the following operations in bulk: (i)processing and packaging of the API messages themselves; (ii) internalobject representation as a list of rows being operated upon; (iii)INSERT routines in PL/SQL; (iv) Lookup routines for de-duplicatematching when doing record updates; (v) UPDATE routines in PL/SQL forrecord changes; (vi) DELETE routines in PL/SQL; (vii) INSERT, UPDATE,DELETE routines include semantically complicated bookkeeping routines,all in bulk, such as: (a) MRU (most-recently used list) maintenance; (b)Row-level sharing maintenance; and (c) Entity store count maintenance;(viii) Reload of data after an update in preparation for performingpost-save logic (known as workflow); and (ix) Workflow implementationitself, including the bulk queue and processing of tasks such as Email,child row creation, outbound SOAP messages, and the like. Eachembodiment disclosed herein may be used or otherwise combined with anyof the other embodiments disclosed. Any element of any embodiment may beused in any embodiment.

While the invention has been described by way of example and in terms ofthe specific embodiments, it is to be understood that the invention isnot limited to the disclosed embodiments. To the contrary, it isintended to cover various modifications and similar arrangements aswould be apparent to those skilled in the art. Therefore, the scope ofthe appended claims should be accorded the broadest interpretation so asto encompass all such modifications and similar arrangements.

1. A method for saving multiple rows together through an objectrelational mapping layer to a database, the method comprising:receiving, at an API in a known start state, a set of rows to savetogether; saving the set of rows together until each row in the set ofrows has been saved; forming a new set of rows from the set of rows byremoving rows associated with faulting during saving; and repeatedlysaving and forming using the new set of rows until a set of rows thatcan be saved from the known start state without fault is determined. 2.The method of claim 1, wherein receiving, at an API in a known startstate, a set of rows to save together includes: receiving information tosave to a set of rows in a Simple Object Access Protocol (SOAP)transaction.
 3. The method of claim 1, wherein saving the set of rowstogether until each row in the set of rows has been saved includes:recording fault information for any row associated with a save operationthat faults.
 4. The method of claim 1, wherein forming a new set of rowsfrom the set of rows by removing rows associated with faulting duringsaving includes: removing rows corresponding to faults from the set ofrows to save together to form the new set of rows to save together. 5.The method of claim 1, wherein repeatedly saving and forming using thenew set of rows until a set of rows that can be saved from the knownstart state without fault is determined includes: rolling back savingthe set of rows to the known start state.
 6. The method of claim 5,wherein rolling back saving the set of rows to the known start stateincludes: rolling back governor limits placed upon code executing onbehalf of rows that are being rolled back.
 7. The method of claim 1,further comprising: committing the set of rows when no fault(s) haveoccurred.
 8. The method of claim 7, thereby enabling: ensuring that noside effects have occurred from executing code on behalf of any rowsfailing to be saved.
 9. A machine-readable medium carrying one or moresequences of instructions for saving multiple rows together through anobject relational mapping layer to a database, which instructions, whenexecuted by one or more processors, cause the one or more processors tocarry out the steps of: receiving, at an API in a known start state, aset of rows to save together; saving the set of rows together until eachrow in the set of rows has been saved; forming a new set of rows fromthe set of rows by removing rows associated with faulting during saving;and repeatedly saving and forming using the new set of rows until a setof rows that can be saved from the known start state without fault isdetermined.
 10. The machine-readable medium as recited in claim 9,wherein the instructions for carrying out the step of receiving, at anAPI in a known start state, a set of rows to save together includeinstructions for carrying out the step of: receiving information to saveto a set of rows in a Simple Object Access Protocol (SOAP) transaction.11. The machine-readable medium as recited in claim 9, wherein theinstructions for carrying out the step of saving the set of rowstogether until each row in the set of rows has been saved includeinstructions for carrying out the step of: recording fault informationfor any row associated with a save operation that faults.
 12. Themachine-readable medium as recited in claim 9, wherein the instructionsfor carrying out the step of forming a new set of rows from the set ofrows by removing rows associated with faulting during saving includeinstructions for carrying out the step of: removing rows correspondingto faults from the set of rows to save together to form the new set ofrows to save together.
 13. The machine-readable medium as recited inclaim 9, wherein the instructions for carrying out the step ofrepeatedly saving and forming using the new set of rows until a set ofrows that can be saved from the known start state without fault isdetermined include instructions for carrying out the step of: rollingback saving the set of rows to the known start state.
 14. Themachine-readable medium as recited in claim 13, wherein the instructionsfor rolling back saving the set of rows to the known start state includeinstructions for carrying out the step of: rolling back governor limitsplaced upon code executing on behalf of rows that are being rolled back.15. The machine-readable medium as recited in claim 9, furthercomprising instructions for carrying out the step of: committing the setof rows when no fault(s) have occurred.
 16. The machine-readable mediumas recited in claim 15, wherein the instructions for committing the setof rows when no fault(s) have occurred include instructions for carryingout the step of: ensuring that no side effects have occurred fromexecuting code on behalf of any rows failing to be saved.
 17. Anapparatus for saving multiple rows together through an object relationalmapping layer to a database, the apparatus comprising: a processor; andone or more stored sequences of instructions which, when executed by theprocessor, cause the processor to carry out the steps of: receiving, atan API in a known start state, a set of rows to save together; savingthe set of rows together until each row in the set of rows has beensaved; forming a new set of rows from the set of rows by removing rowsassociated with faulting during saving; and repeatedly saving andforming using the new set of rows until a set of rows that can be savedfrom the known start state without fault is determined.
 18. A method fortransmitting code for saving multiple rows together through an objectrelational mapping layer to a database on a transmission medium, themethod comprising: transmitting code to receive, at an API in a knownstart state, a set of rows to save together; transmitting code to savethe set of rows together until each row in the set of rows has beensaved; transmitting code to form a new set of rows from the set of rowsby removing rows associated with faulting during saving; andtransmitting code to repeatedly save and form using the new set of rowsuntil a set of rows that can be saved from the known start state withoutfault is determined.
 19. A method for saving multiple rows togetherthrough an object relational mapping layer to a database, the methodcomprising: (A) receiving, at an API in a known start state, a set ofrows to save together; (B) attempting to save the set of rows together,while recording fault information for any save operation that faults,until each row in the set of rows has been attempted at least once; and(c) committing the save of the entire set of rows if no fault(s) haveoccurred; otherwise (i) rolling back the save of the entire set of rowsto the known start state; (ii) removing rows corresponding to faultsfrom the set of rows to save together to form a subset of rows to savetogether; and (iii) repeating steps (B)-(C) using the subset of rows asa new set of rows to save together until a subset of rows that can besaved and committed without fault is found.